package com.company.anr.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * ANR分析器配置类
 * 用于读取application.properties中的配置
 */
@Configuration
@ConfigurationProperties(prefix = "anr")
public class AnrConfig {

  /**
   * 基础工作目录
   */
  private String workDirectory = "D:/ANR-WORK";

  /**
   * 详细分析报告目录
   */
  private String detailDirectory = "D:/ANR-WORK-DETAIL";

  /**
   * 处理后的文件目录（以SN命名的文件夹）
   */
  private String processedDirectory = "D:/ANR-WORK/processed";

  /**
   * 临时文件目录
   */
  private String tempDirectory = "D:/ANR-WORK/temp";

  /**
   * 自动化等待时间配置（秒）
   */
  private int automationNotificationWaitSeconds = 120;

  // Getters and Setters
  public String getWorkDirectory() {
    return workDirectory;
  }

  public void setWorkDirectory(String workDirectory) {
    this.workDirectory = workDirectory;
  }

  public String getDetailDirectory() {
    return detailDirectory;
  }

  public void setDetailDirectory(String detailDirectory) {
    this.detailDirectory = detailDirectory;
  }

  public String getProcessedDirectory() {
    return processedDirectory;
  }

  public void setProcessedDirectory(String processedDirectory) {
    this.processedDirectory = processedDirectory;
  }

  public String getTempDirectory() {
    return tempDirectory;
  }

  public void setTempDirectory(String tempDirectory) {
    this.tempDirectory = tempDirectory;
  }

  public int getAutomationNotificationWaitSeconds() {
    return automationNotificationWaitSeconds;
  }

  public void setAutomationNotificationWaitSeconds(int automationNotificationWaitSeconds) {
    this.automationNotificationWaitSeconds = automationNotificationWaitSeconds;
  }

  /**
   * 获取指定SN的处理后文件路径
   *
   * @param deviceSn 设备SN
   * @return 处理后文件路径
   */
  public String getProcessedPathForSn(String deviceSn) {
    return processedDirectory + "/" + deviceSn;
  }

  /**
   * 获取指定SN的详细分析报告路径
   *
   * @param deviceSn 设备SN
   * @return 详细分析报告路径
   */
  public String getDetailReportPathForSn(String deviceSn) {
    return detailDirectory + "/" + deviceSn + "_analysis.txt";
  }

  /**
   * 获取指定SN的工作目录路径
   *
   * @param deviceSn 设备SN
   * @return 工作目录路径
   */
  public String getWorkPathForSn(String deviceSn) {
    return workDirectory + "/" + deviceSn;
  }

  /**
   * 获取临时日志文件路径
   *
   * @return 临时日志文件路径
   */
  public String getTempLogPath() {
    return workDirectory + "/tmp_log.txt";
  }
}